package org.xu.upms.server.dao.impl;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

import org.springframework.stereotype.Repository;
import org.xu.upms.server.dao.AppDao;
import org.xu.upms.server.model.App;

import com.xu.commons.dao.Database;
import com.xu.commons.dao.mpl.BaseDaoImpl;
@Repository
public class AppDaoImpl extends BaseDaoImpl<App,Integer> implements AppDao {

	@Override
	public App findByCode(String code) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<App> findByUserId(Boolean isEnable, Integer userId) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public List<String> findAppCodeByUserId(Boolean isEnable, Integer userId) {
		// 在 user 表中根据 username 查询用户是否已存在

        String sql="	SELECT a.code FROM SYS_APP a WHERE a.isEnable = ? "+
			"AND EXISTS (" +
				"SELECT 1 "+
				"FROM SYS_RE_USER_APP ua "+
				"WHERE ua.appId = a.id "+
				"AND ua.userId = ?)";
        List<String> result = Database.queryColumnList(sql, isEnable,userId);
		return result;
	}



}
